<?php
/*
+---------------------------------------------------------------------------
|   Arka-Tech Web Application v1.2.0
|   ========================================
|   by Christopher Hall
|   (c) 2009 Arka-Tech Productions
|   http://arka-tech.net
|   ========================================
|   Web: http://www.SITENAME.com
|   Time: Sat, 28 Feb 2009 9:05 AM
|   Release: RmVicnVhcnkgMjAwOSBMYXVuY2ggNA==
|   Email: ArkahnX@gmail.com
|   Licence Info: http://www.arka-tech.net/default.php?page=license
+---------------------------------------------------------------------------
*/

if ($_REQUEST['action']) {
	$_SESSION['action'] = $_REQUEST['action'];
}
if ($_REQUEST['password']) {
	$_SESSION['password'] = md5($_REQUEST['password'] . md5($_REQUEST['password']));
}

include_once('CORE.inc.php');
$xml = xml_xml2array(file_get_contents(path_account(REAL_ROOTUSER)));
if (in_array($_SESSION['action'],array('remove-installer','uninstall')) && $_SESSION['password'] == $xml['ATUser'][0]['password'][0]) {
	include(INSTALL_DIR . 'modules/system/' . $_SESSION['action'] . '.php');
} else {
	system_start($_REQUEST['action'],$_REQUEST['password']);
}

function system_start($action,$password) {
	include_once('CORE.inc.php');
	$xml = xml_xml2array(file_get_contents(path_account(REAL_ROOTUSER)));
	if (isset($password) && md5($password . md5($password)) != $xml['ATUser'][0]['password'][0]) {
		$errorPassword = lang_translate('installer-system-password-error','Incorrect root password!');
	}
	$content = '<div class="system" style="top: 142px;">
	<ul>
		<li>
			' . lang_translate('installer-system-message-translations','Translations can be downloaded from [a link].',array('[a link]' => '<a onclick="window.open(this.href); return false;" href="http://arka-tech.net/default.php?page=Download">http://arka-tech.net/</a>')) . '
			<br />
			<br />
			<br />
		</li>
		<li><span style="font-weight: bold;">' . lang_translate('installer-system-message-remove','Please remove the installer for security reasons!') . '</span></li>
	</ul>
</div>
<form action="./index.php" method="post">
	<div class="actions">
		<div class="action_text">' . lang_translate('installer-system-action','Action') . '</div>
		<select class="action" name="action">
			<option value="remove-installer"';
			if ($action == 'remove-installer') $content .= ' selected="selected"';
			$content .= '>' . lang_translate('installer-system-action-removeinstaller','Remove the ATWA installer') . '</option>
			<option value="uninstall"';
			if ($action == 'uninstall') $content .= ' selected="selected"';
			$content .= '>' . lang_translate('installer-system-action-uninstall','Uninstall ATWA') . '</option>
		</select>
		<div class="password_text">' . lang_translate('installer-system-password','Root password') . '</div>
		<input class="password" name="password" type="password" value="" />
		<div class="errorPassword">' . $errorPassword . '</div>
	</div>
	<div class="button"><input class="iButton" type="submit" value="' . lang_translate('installer-system-continue','Continue...') . '" /></div>
</form>';
	output_do($content,'system',lang_translate('installer-system-title','Please choose one of the following actions:'));
}
?>